<?php
/**
 * Created by PhpStorm.
 * Date: 2015/12/11
 * Time: 9:46
 */

namespace app\api\controllers;


use app\api\Response;
use app\models\Lunwen;
use yii\helpers\ArrayHelper;
use yii\web\Controller;

class PaperController extends Controller
{

    public function actionList($pageNow, $pageSize)
    {

        $list = Lunwen::getList($pageNow, $pageSize);
        Response::setHeader();
        echo json_encode(ArrayHelper::toArray($list));
    }

    public function actionDetail($id){

        $detail = Lunwen::findOne(['id'=>$id]);
        Response::setHeader();
        echo json_encode(ArrayHelper::toArray($detail));
    }
    /**
     * 搜索功能
     * @param type $lwname
     * @return type
     */
    public function actionSearch($lwname) {
        $lwnames=  Lunwen::find()
              ->where(['or',['like','author',$lwname],['like','lwname',$lwname]])
              ->all();
      Response::setHeader();
      return json_encode(\yii\helpers\ArrayHelper::toArray($lwnames));
    }

}